package com.topdt.jbpm.web.servlet.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.thx.common.spring.BeanFactory;
import com.topdt.jbpm.form.TemplateCreater;
import com.topdt.jbpm.service.FormService;
import com.topdt.jbpm.web.servlet.JbpmServlet;

/**
 * 表单定义相关（从JbpmServlet中迁移过来）
 *
 * @author balancejia
 *
 */
public class FormAction extends JbpmBaseAction {

  public FormAction(JbpmServlet servlet) {
    super(servlet);
  }

  /**
   * 获得模板
   */
  public void creatTemplate(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    String formId = request.getParameter("formId");
    FormService formService = (FormService) BeanFactory.getBean("formService");
    String template = TemplateCreater.getTemplate(formService.get(formId));
    response.setContentType("text/html;charset=utf-8");
    response.getWriter().write(template);
  }
}
